home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / PowerPlant / CGI++ Framework / <CGI Starter Source>.cp < prev    next >
Encoding:
Text File  |  1995-11-17  |  4.7 KB  |  165 lines  |  [TEXT/CWIE]

  1. // ===========================================================================
  2. //    <CGI Starter Source>.cp    ©1995 Brian Todoroff  All rights reserved.
  3. //                      Portions ©1994-1995 Metrowerks Inc. All rights reserved.
  4. // ===========================================================================
  5. //
  6. //    This file contains the starter code for a PowerPlant CGI application
  7. //  that is compatible with the calling conventions of MacHTTP and WebSTAR.
  8. //
  9. //    Much of what you find here comes from the CW7 <PP Starter Source>
  10.  
  11. #include "<CGI Starter Header>.h"
  12.  
  13. #include <LGrowZone.h>
  14. #include <LWindow.h>
  15. #include <PP_Messages.h>
  16. #include <PP_Resources.h>
  17. #include <PPobClasses.h>
  18. #include <UDrawingState.h>
  19. #include <UMemoryMgr.h>
  20. #include <URegistrar.h>
  21. #include <LEditField.h>
  22.  
  23. // ===========================================================================
  24. //        • Main Program
  25. // ===========================================================================
  26.  
  27. void main(void)
  28. {
  29.                                     // Set Debugging options
  30.     SetDebugThrow_(debugAction_Alert);
  31.     SetDebugSignal_(debugAction_Alert);
  32.  
  33.     InitializeHeap(3);                // Initialize Memory Manager
  34.                                     // Parameter is number of Master Pointer
  35.                                     //   blocks to allocate
  36.     
  37.                                     // Initialize standard Toolbox managers
  38.     UQDGlobals::InitializeToolbox(&qd);
  39.     
  40.     new LGrowZone(20000);            // Install a GrowZone function to catch
  41.                                     //    low memory situations.
  42.  
  43.     CGIStarterApp    theApp;            // replace this with your App type
  44.     theApp.Run();
  45. }
  46.  
  47.  
  48. // ---------------------------------------------------------------------------
  49. //        • CPPStarterApp             // replace this with your App type
  50. // ---------------------------------------------------------------------------
  51. //    Constructor
  52.  
  53. CGIStarterApp::CGIStarterApp()
  54. {
  55.     // Register functions to create core PowerPlant classes
  56.     
  57.     RegisterAllPPClasses();
  58. }
  59.  
  60.  
  61. // ---------------------------------------------------------------------------
  62. //        • ~CPPStarterApp            // replace this with your App type
  63. // ---------------------------------------------------------------------------
  64. //    Destructor
  65. //
  66.  
  67. CGIStarterApp::~CGIStarterApp()
  68. {
  69. }
  70.  
  71. // ---------------------------------------------------------------------------
  72. //        • StartUp
  73. // ---------------------------------------------------------------------------
  74. //    This function lets you do something when the application starts up. 
  75. //    For example, you could issue your own new command, or respond to a system
  76. //  oDoc (open document) event.
  77.  
  78. void
  79. CGIStarterApp::StartUp()
  80. {
  81. }
  82.  
  83. // ---------------------------------------------------------------------------
  84. //        • ObeyCommand
  85. // ---------------------------------------------------------------------------
  86. //    Respond to commands
  87.  
  88. Boolean
  89. CGIStarterApp::ObeyCommand(
  90.     CommandT    inCommand,
  91.     void        *ioParam)
  92. {
  93.     Boolean        cmdHandled = true;
  94.  
  95.     switch (inCommand) {
  96.     
  97.         // Deal with command messages (defined in PP_Messages.h).
  98.         // Any that you don't handle will be passed to LApplication
  99.  
  100.         default:
  101.             cmdHandled = LApplication::ObeyCommand(inCommand, ioParam);
  102.             break;
  103.     }
  104.     
  105.     return cmdHandled;
  106. }
  107.  
  108. // ---------------------------------------------------------------------------
  109. //        • FindCommandStatus
  110. // ---------------------------------------------------------------------------
  111. //    This function enables menu commands.
  112. //
  113.  
  114. void
  115. CGIStarterApp::FindCommandStatus(
  116.     CommandT    inCommand,
  117.     Boolean        &outEnabled,
  118.     Boolean        &outUsesMark,
  119.     Char16        &outMark,
  120.     Str255        outName)
  121. {
  122.  
  123.     switch (inCommand) {
  124.     
  125.         // Return menu item status according to command messages.
  126.         // Any that you don't handle will be passed to LApplication
  127.  
  128.         default:
  129.             LApplication::FindCommandStatus(inCommand, outEnabled,
  130.                                                 outUsesMark, outMark, outName);
  131.             break;
  132.     }
  133. }
  134.  
  135. void CGIStarterApp::HandleCGICall(struct CGIData &data,LCHandleStream &sout)
  136. {
  137.     sout<<"This is being served from the GCI++ Framework by Brian Todoroff"<<endl;
  138.     sout<<endl;
  139.     sout<<"You must change the HandleCGICall routine in your application."<<endl;
  140.     sout<<endl;
  141.     sout<<"The data recived is "<<endl;
  142.     sout<<"direct:    "<<data.direct<<endl;
  143.     sout<<"search:    "<<data.search<<endl;
  144.     sout<<"uname:    "<<data.uname<<endl;
  145.     sout<<"pass:    "<<data.pass<<endl;
  146.     sout<<"fromuser:"<<data.fromuser<<endl;
  147.     sout<<"caddr:   "<<data.caddr<<endl;
  148.     sout<<"post:    "<<data.post<<endl;
  149.     sout<<"method:    "<<data.method<<endl;
  150.     sout<<"sname:   "<<data.sname<<endl;
  151.     sout<<"sport:   "<<data.sport<<endl;
  152.     sout<<"cginame: "<<data.cginame<<endl;
  153.     sout<<"ctype:   "<<data.ctype<<endl;
  154.     sout<<"referer: "<<data.referer<<endl;
  155.     sout<<"agent:   "<<data.agent<<endl;
  156.     sout<<endl;
  157.     sout<<"<H3>That's It For Now!</H3>"<<endl;
  158.     sout<<endl<<"Based on the CGI++ Framework for PowerPlant"<<endl;
  159.     sout<<"Contact the author at: btodorof@hmc.edu"<<endl;
  160.     sout<<"Bug reports and suggestions appreciated."<<endl;
  161.     
  162.     return;
  163. }
  164.  
  165.